package com.example.java.source;

import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;

import java.util.Properties;

public class KafkaSourceMain {
    public static void main(String[] args) throws Exception {
        String topic = "mytopic";
        Properties prop = new Properties();
        prop.setProperty("bootstrap.servers","linux121:9092,linux122:9092,linux123:9092");
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource data = env.addSource(
                new FlinkKafkaConsumer(topic, new SimpleStringSchema(), prop));

        data.print();

        env.execute();
    }
}
